package com.zzyl.nursing.controller;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zzyl.nursing.dto.MyDTO;
import com.zzyl.nursing.vo.MyVO;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

@RestController
@RequestMapping("my")
public class MyController {

    @GetMapping("/get")
    public String testGet(@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date myDate){
        System.out.println("myDate = " + myDate);
        return "success";
    }

    @PostMapping("post")
    public MyVO testPost(@RequestBody MyDTO myDTO){
        System.out.println("myDTO = " + myDTO);
        MyVO myVO = new MyVO();
        myVO.setDate(new Date());
        myVO.setLocalDateTime(LocalDateTime.now());
        return myVO;
    }
}
